<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-commands.html" />
<link rel="prev" href="module-nis.html" />
<link rel="parent" href="unix.html" />
<link rel="next" href="module-commands.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>16.15 syslog -- Unix syslog library routines</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="16.14 nis  "
  href="module-nis.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="16. unix Specific Services"
  href="unix.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="16.16 commands  "
  href="module-commands.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-nis.html">16.14 nis  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="unix.html">16. Unix Specific Services</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-commands.html">16.16 commands  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION00181500000000000000000">
16.15 <tt class="module">syslog</tt> --
         <span class="Unix">Unix</span> syslog library routines</a>
</h1>

<p>
<a name="module-syslog"></a>  
<p class="availability">Availability: <span
 class="platform">Unix</span>.</p>

<p>
This module provides an interface to the <span class="Unix">Unix</span> <code>syslog</code> library
routines.  Refer to the <span class="Unix">Unix</span> manual pages for a detailed description
of the <code>syslog</code> facility.

<p>
The module defines the following functions:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3618' xml:id='l2h-3618' class="function">syslog</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>priority,</var><big>]</big><var> message</var>)</td></tr></table></dt>
<dd>
Send the string <var>message</var> to the system logger.  A trailing
newline is added if necessary.  Each message is tagged with a priority
composed of a <var>facility</var> and a <var>level</var>.  The optional
<var>priority</var> argument, which defaults to <tt class="constant">LOG_INFO</tt>,
determines the message priority.  If the facility is not encoded in
<var>priority</var> using logical-or (<code>LOG_INFO | LOG_USER</code>), the
value given in the <tt class="function">openlog()</tt> call is used.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3619' xml:id='l2h-3619' class="function">openlog</tt></b>(</nobr></td>
  <td><var>ident</var><big>[</big><var>, logopt</var><big>[</big><var>, facility</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Logging options other than the defaults can be set by explicitly
opening the log file with <tt class="function">openlog()</tt> prior to calling
<tt class="function">syslog()</tt>.  The defaults are (usually) <var>ident</var> =
<code>'syslog'</code>, <var>logopt</var> = <code>0</code>, <var>facility</var> =
<tt class="constant">LOG_USER</tt>.  The <var>ident</var> argument is a string which is
prepended to every message.  The optional <var>logopt</var> argument is a
bit field - see below for possible values to combine.  The optional
<var>facility</var> argument sets the default facility for messages which
do not have a facility explicitly encoded.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3620' xml:id='l2h-3620' class="function">closelog</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Close the log file.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3621' xml:id='l2h-3621' class="function">setlogmask</tt></b>(</nobr></td>
  <td><var>maskpri</var>)</td></tr></table></dt>
<dd>
Set the priority mask to <var>maskpri</var> and return the
previous mask value.  Calls to <tt class="function">syslog()</tt> with a priority
level not set in <var>maskpri</var> are ignored.  The default is to log all
priorities.  The function <code>LOG_MASK(<var>pri</var>)</code> calculates the
mask for the individual priority <var>pri</var>.  The function
<code>LOG_UPTO(<var>pri</var>)</code> calculates the mask for all priorities up
to and including <var>pri</var>.
</dl>

<p>
The module defines the following constants:

<p>
<dl>
<dt><strong>Priority levels (high to low):</strong></dt>
<dd><p>
<tt class="constant">LOG_EMERG</tt>, <tt class="constant">LOG_ALERT</tt>, <tt class="constant">LOG_CRIT</tt>,
<tt class="constant">LOG_ERR</tt>, <tt class="constant">LOG_WARNING</tt>, <tt class="constant">LOG_NOTICE</tt>,
<tt class="constant">LOG_INFO</tt>, <tt class="constant">LOG_DEBUG</tt>.

<p>
</dd>
<dt><strong>Facilities:</strong></dt>
<dd><p>
<tt class="constant">LOG_KERN</tt>, <tt class="constant">LOG_USER</tt>, <tt class="constant">LOG_MAIL</tt>,
<tt class="constant">LOG_DAEMON</tt>, <tt class="constant">LOG_AUTH</tt>, <tt class="constant">LOG_LPR</tt>,
<tt class="constant">LOG_NEWS</tt>, <tt class="constant">LOG_UUCP</tt>, <tt class="constant">LOG_CRON</tt> and
<tt class="constant">LOG_LOCAL0</tt> to <tt class="constant">LOG_LOCAL7</tt>.

<p>
</dd>
<dt><strong>Log options:</strong></dt>
<dd><p>
<tt class="constant">LOG_PID</tt>, <tt class="constant">LOG_CONS</tt>, <tt class="constant">LOG_NDELAY</tt>,
<tt class="constant">LOG_NOWAIT</tt> and <tt class="constant">LOG_PERROR</tt> if defined in
<code>&lt;syslog.h&gt;</code>.

<p>
</dd>
</dl>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="16.14 nis  "
  href="module-nis.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="16. unix Specific Services"
  href="unix.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="16.16 commands  "
  href="module-commands.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-nis.html">16.14 nis  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="unix.html">16. Unix Specific Services</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-commands.html">16.16 commands  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
